require.config(require_config);

define([
    'jquery',
    'common',
    'ready',
    'template',
    'collection',
    'model',
    'dialog',
    'datepicker'
], function ($, common, ready, template, Collection, Model, dialog, datepicker) {

    var index = function () {
        this.init();
    };
    var flare_data;
    index.prototype = {
        init: function () {

            this.event();
            this.fetch();
        },

        fetch: function () {
            var _this = this;
            this.collection = new Collection({
                container: 'data-list',
                template: 'data-item',
                url: _global.url.api + 'user/master/user_tracks',
                condition: {
                    limit: 10,
                    offset: 0
                },
                callback: function () {
                    loaded();
                }
            });
            this.collection.fetch();
        },
        event: function () {
            var _this = this;

            //日期
            $('.long_date').on('click', function () {
                WdatePicker({
                    el: this.id,
                    dateFmt: 'yyyy-MM-dd HH:mm'
                });
            });

            $('#btn-search').on('click', function (e) {
                e.preventDefault();
                _this.collection.condition.dateTime = $('input[name="dateTime"]').val();
                _this.collection.condition.maxUid   = $('input[name="maxUid"]').val();
                _this.collection.condition.minUid   = $('input[name="minUid"]').val();
                _this.collection.condition.oneUid   = $('input[name="oneUid"]').val();
                _this.collection.reload();
            });

            /**
             * 按状态查询
             */
            $('.btn-banned_user').on('click', function (e) {
                e.preventDefault();

                _this.collection.condition.status = $(e.target).attr('rel');
                _this.collection.reload();
                $(e.target).addClass('active').siblings().removeClass('active');
            });
        }
    };

    new index();

});